/* 
 * File:   BufferTest.cpp
 * Author: max
 *
 * Created on May 23, 2013, 10:00:38 PM
 */

#include <stdlib.h>
#include <iostream>
#include <string.h>
#include "common_Buffer.h"
#include "common_Excepcion.h"

using namespace std;
using namespace TP;
/*
 * Simple C++ Test Suite
 */

void testBuffer() {
    try
    {
        string aux = "casa";
        
        TP::Buffer buffer(aux.length() +1);
        
        buffer.Write(reinterpret_cast <const uint8_t*>(aux.c_str()), aux.length());

        if (aux != reinterpret_cast <char*>(buffer.c_buffer())) {
            std::cout << "%TEST_FAILED% time=0 testname=testBuffer (BufferTest) message=El buffer no contiene la info escrita." << std::endl;
        }
        
        buffer.Zero();
        aux = "";
        if (aux != reinterpret_cast <char*> (buffer.c_buffer()))
        {
            std::cout << "%TEST_FAILED% time=0 testname=testBuffer (BufferTest) message=buffer.zero no funk." << std::endl;
        }
        
    }
    catch (Excepcion &ex)
    {
        std::cout << "%TEST_FAILED% time=0 testname=testBuffer (BufferTest) message=" << ex.what() << std::endl;
    }
}

//void testSize() {
//    TP::Buffer buffer;
//    uint32_t& result = buffer.Size();
//    if (true /*check result*/) {
//        std::cout << "%TEST_FAILED% time=0 testname=testSize (BufferTest) message=error message sample" << std::endl;
//    }
//}
//
//void testWrite() {
//    uint8_t*& pData;
//    uint32_t& pBytesQuantity;
//    TP::Buffer buffer;
//    uint32_t& result = buffer.Write(pData, pBytesQuantity);
//    if (true /*check result*/) {
//        std::cout << "%TEST_FAILED% time=0 testname=testWrite (BufferTest) message=error message sample" << std::endl;
//    }
//}
//
//void testC_buffer() {
//    TP::Buffer buffer;
//    uint8_t*& result = buffer.c_buffer();
//    if (true /*check result*/) {
//        std::cout << "%TEST_FAILED% time=0 testname=testC_buffer (BufferTest) message=error message sample" << std::endl;
//    }
//}

int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% BufferTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% testBuffer (BufferTest)" << std::endl;
    testBuffer();
    std::cout << "%TEST_FINISHED% time=0 testBuffer (BufferTest)" << std::endl;
//
//    std::cout << "%TEST_STARTED% testSize (BufferTest)" << std::endl;
//    testSize();
//    std::cout << "%TEST_FINISHED% time=0 testSize (BufferTest)" << std::endl;
//
//    std::cout << "%TEST_STARTED% testWrite (BufferTest)" << std::endl;
//    testWrite();
//    std::cout << "%TEST_FINISHED% time=0 testWrite (BufferTest)" << std::endl;
//
//    std::cout << "%TEST_STARTED% testC_buffer (BufferTest)" << std::endl;
//    testC_buffer();
//    std::cout << "%TEST_FINISHED% time=0 testC_buffer (BufferTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

